<p:dialog xmlns="http://www.w3.org/1999/xhtml"
      	  xmlns:h="http://java.sun.com/jsf/html"
      	  xmlns:f="http://java.sun.com/jsf/core"
      	  xmlns:ui="http://java.sun.com/jsf/facelets"
      	  xmlns:p="http://primefaces.org/ui"
      	  modal="true"  resizable="true" width="50%"
		  widgetVar="dialogManterAluno" id="idDialogManterAluno" closable="true"
		  appendTo="@(body)" header="Cadastrar Novo Aluno"> 	
  	
	 <link rel="stylesheet" type="text/css" href="./estilos.css"/>  
<h:form id="formDialogManterAluno" prependId="false">
<h:panelGroup id="pgMatriculaManterAluno">
 	<p:messages id="messagesMatriculaManterAluno" autoUpdate="true" closable="true" />  
    	<h:panelGrid  columns="2" style="margin-top:20px; margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Nome do Aluno*" styleClass="outputLabel"/>             
            <p:inputText id="inputCodigo" value="#{matriculaBean.aluno.idAluno}" styleClass="inputId" disabled="true">
            	<p:ajax listener="#{matriculaBean.ajaxGet}"/>
            </p:inputText>  
  			<p:inputText value="#{matriculaBean.aluno.nome}" styleClass="inputDescricao" maxlength="40" required="true" requiredMessage="Informar o nome do Aluno!">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>  
        </h:panelGrid>  
        <h:panelGrid  columns="2" style="margin-right:10%;">  
            <h:outputLabel value="Logradouro*" styleClass="outputLabel"/>  
            <h:outputLabel value="Número*" styleClass="outputLabel"/>  
            <p:inputText value="#{matriculaBean.aluno.logradouro}" styleClass="inputDescricao" maxlength="40" required="true" requiredMessage="Informar o logradouro!">
            	<p:ajax listener="#{matriculaBean.ajaxGet}"/>
            </p:inputText>  
  			<p:inputText value="#{matriculaBean.aluno.numero}" styleClass="inputId" required="true" maxlength="10" requiredMessage="Informar o número do logradouro!">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>  
        </h:panelGrid>         
       	<h:panelGrid  columns="3" style="margin-right:10%;">  
            <h:outputLabel value="Complemento" styleClass="outputLabel"/>  
            <h:outputLabel value="Bairro" styleClass="outputLabel"/>             
            <h:outputLabel value="CEP" styleClass="outputLabel"/>  
            <p:inputText value="#{matriculaBean.aluno.complemento}" styleClass="inputDescricao" maxlength="40" >
            	<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>               
  			<p:inputText value="#{matriculaBean.aluno.bairro}" styleClass="inputData"  maxlength="40" >
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>    
  			<p:inputMask mask="99.999-999" value="#{matriculaBean.aluno.cep}" styleClass="inputData">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputMask>    
        </h:panelGrid> 
        <h:panelGroup>
        <h:panelGrid id="pgMatriculaAlunoCidade" columns="5" style="margin-right:10%;">  
            <h:outputLabel value="Código*" styleClass="outputLabel"/>  
            <h:outputLabel value="Cidade*" styleClass="outputLabel"/>             
            <h:outputLabel /> 
            <h:outputLabel value="Estado" styleClass="outputLabel"/>             
            <h:outputLabel value="País" styleClass="outputLabel"/>                        
            <p:inputText value="#{matriculaBean.aluno.cidade.idCidade}" styleClass="inputId" maxlength="5">
            	<p:ajax  listener="#{matriculaBean.onChangeCidade}"  update="pgMatriculaAlunoCidade, messagesMatriculaManterAluno"/>
            </p:inputText>  
  			<p:inputText id="idCidadeDescricao" value="#{matriculaBean.aluno.cidade.descricao}" maxlength="40" styleClass="inputDescricao">
  				<p:ajax  listener="#{matriculaBean.onChangeCidadeNull}"  update="pgMatriculaAlunoCidade, messagesMatriculaManterAluno"/>
			</p:inputText> 
  			<p:commandButton icon="ui-icon-search" actionListener="#{matriculaBean.openDialogConsultarCidade}" process="@this" immediate="true"/> 
  			<p:inputText value="#{matriculaBean.aluno.cidade.estado.sigla}" styleClass="inputId" disabled="true"/>
  			<p:inputText value="#{matriculaBean.aluno.cidade.estado.pais.descricao}" styleClass="inputDescricao" disabled="true"/>
        </h:panelGrid> 
        </h:panelGroup>
        <h:panelGrid  columns="5" style="margin-right:10%;">  
            <h:outputLabel value="Data de Nascimento*" styleClass="outputLabel"/>  
            <h:outputLabel value="Sexo" />  
            <h:outputLabel value="RG" styleClass="outputLabel"/>             
            <h:outputLabel value="UF" styleClass="outputLabel"/> 
            <h:outputLabel value="CPF" styleClass="outputLabel"/>                 
            
            <p:inputMask value="#{matriculaBean.aluno.dtNascimento}" mask="99/99/9999" styleClass="inputData"
            				required="true" requiredMessage="Informar a 'Data de Nascimento'!">
           		<f:convertDateTime dateStyle="medium"/>
           		<p:ajax listener="#{matriculaBean.ajaxGet}"/>
            </p:inputMask>  
            <p:selectOneMenu value="#{matriculaBean.aluno.sexo}">
            	<f:selectItems value="#{matriculaBean.arraySexo}" />
            </p:selectOneMenu>             
  			<p:inputText value="#{matriculaBean.aluno.rg}" maxlength="40"  style="width:100px;" styleClass="inputDescricao">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>   
  			<p:inputText value="#{matriculaBean.aluno.ufRg}" maxlength="2"  style="width:50px;" styleClass="inputDescricao">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>   			
  			<p:inputMask value="#{matriculaBean.aluno.cpf}" mask="999.999.999-99" styleClass="inputTelefone" >
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  				<p:ajax listener="#{matriculaBean.validaCpf}"/>
  			</p:inputMask>
        </h:panelGrid> 
        <h:panelGrid  columns="1" style="margin-right:10%;">  
            <h:outputLabel value="Profissão*" styleClass="outputLabel"/>       
  			<p:inputText value="#{matriculaBean.aluno.profissao}" maxlength="40" styleClass="inputDescricao">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>    
        </h:panelGrid> 
        <h:panelGrid columns="1" style="text-align:center; margin-right:10%;"> 
         	<h:outputLabel value="Telefones para Contato" styleClass="outputLabel"/>      
		</h:panelGrid> 
        <h:panelGrid columns="3" style="margin-right:10%;">             
            <h:outputLabel value="Residencial" styleClass="outputLabel"/>      
            <h:outputLabel value="Celular" styleClass="outputLabel"/>  
            <h:outputLabel value="Comercial" styleClass="outputLabel"/>               
  			<p:inputMask value="#{matriculaBean.aluno.residencial}" mask="(99) 9999-9999" styleClass="inputTelefone">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputMask>  
  			<p:inputMask value="#{matriculaBean.aluno.celular}" mask="(99) 9999-9999" styleClass="inputTelefone" >
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputMask> 
  			<p:inputMask value="#{matriculaBean.aluno.telefoneComercial}" mask="(99) 9999-9999"  styleClass="inputTelefone">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputMask> 
        </h:panelGrid> 
        <h:panelGrid  columns="1" style="text-align:center; margin-right:10%;">  
            <h:outputLabel value="E-mail" styleClass="outputLabel"/>       
  			<p:inputText value="#{matriculaBean.aluno.email}" maxlength="40" styleClass="inputDescricao">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>    
        </h:panelGrid> 
        <h:panelGrid  columns="1" style="text-align:center; margin-right:10%;">  
            <h:outputLabel value="Responsável (Obrigatório para menores de 18 anos)" styleClass="outputLabel"/>       
  			<p:inputText value="#{matriculaBean.aluno.responsavel}" maxlength="40" styleClass="inputDescricao">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputText>  
        </h:panelGrid> 
        <h:panelGrid  columns="1" style="margin-right:10%;">  
            <h:outputLabel value="Observação" styleClass="outputLabel"/>       
  			<p:inputTextarea value="#{matriculaBean.aluno.observacao}" rows="3" cols="100" style="font-size:14px;" maxlength="255">
  				<p:ajax listener="#{matriculaBean.ajaxGet}"/>
  			</p:inputTextarea>  
        </h:panelGrid>
    <p:commandButton value="Salvar" actionListener="#{matriculaBean.saveAluno}" process="@this" update="pgMatriculaManterAluno"  /> 
	<p:commandButton value="Sair" actionListener="#{matriculaBean.closeManterAluno}" process="@this" immediate="true" style="margin-right:20px;" /> 
</h:panelGroup>
</h:form>  	
<ui:include src="/view/matricula/dialogConsultarCidade.xhtml"></ui:include>
</p:dialog>
